package org.library.menu;

import org.library.controller.BookController;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.stereotype.Component;

/**
 * 用户菜单
 *
 * @author Chen
 * @since 2023/6/13 15:21
 */
@Component
public class UserMenu extends Menu {

    public UserMenu(BeanFactory beanFactory) {
        super(beanFactory);
    }

    @Override
    public void menu() {
        System.out.println("欢迎使用图书管理系统");
        System.out.println("1.查询所有图书");
        System.out.println("2.借阅图书");
        System.out.println("3.归还图书");
        System.out.println("4.登出");
        System.out.println("请输入你的选择：");
        String select = scanner.next();
        switch (select) {
            case "1":
                controllerFactory.getController(BookController.class).list().forEach(System.out::println);
                break;
            case "2":
                break;
            case "3":
                break;
            case "4":
                library.setLoginUser(null);
                library.setMenu(beanFactory.getBean(MainMenu.class));
                break;
            default:
                break;
        }
        library.run();
    }

}
